archive/tar: test tarinsecurepath behavior for link targets#79885
archive/tar: test tarinsecurepath behavior for link targets#79885Abhinav-143x wants to merge 1 commit into
Conversation
|
This PR (HEAD: e361d77) has been imported to Gerrit for code review. Please visit Gerrit at https://go-review.googlesource.com/c/go/+/787880. Important tips:
|
|
Message from Gopher Robot: Patch Set 1: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/787880. |
|
Message from Gopher Robot: Patch Set 1: Congratulations on opening your first change. Thank you for your contribution! Next steps: Most changes in the Go project go through a few rounds of revision. This can be During May-July and Nov-Jan the Go project is in a code freeze, during which Please don’t reply on this GitHub thread. Visit golang.org/cl/787880. |
|
Message from Abhinav Gaur: Patch Set 2: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/787880. |
Clarify the Reader.Next documentation for tarinsecurepath=0 and add
regression coverage for link targets.
The tarinsecurepath check reports ErrInsecurePath for non-local Header.Name
values, but it does not validate Header.Linkname. That distinction matters for
archive consumers that use archive/tar as part of extraction or policy
enforcement: link targets need to be handled by the extractor's own filesystem
policy.
This change preserves the current behavior. It rewords the Reader.Next comment
so the ErrInsecurePath behavior reads directly, keeps the existing statement
that only file names are validated, and adds tests for TypeLink and TypeSymlink
entries with non-local link targets while GODEBUG=tarinsecurepath=0.
The new test confirms that the tarinsecurepath check applies to the entry name
and not to the link target. This should help prevent future regressions or
ambiguous assumptions around link handling in archive/tar readers.
No issue: this is a documentation and test clarification for existing behavior.
Tests:
Review requested. Please let me know if this should be adjusted to emphasize
the test coverage only, or if there is a preferred wording for the Reader.Next
documentation.